; (function () {
    //移入左边menuBoxDowm1添加边框,mid_infBox显示
    $(function () {
        $(".menuBoxDown1 li").on("mouseenter", function () {
            $(this).find(".mid_infBox").css("display", "block");
            $(this).css("border", "1px solid red")
            $(this).css("border-right", "none")
            $(this).parents(".menu").find(".menuBoxDown2").css("display", "none")
        });
        $(".menuBoxDown1 li").on("mouseleave", function () {
            $(this).find(".mid_infBox").css("display", "none");
            $(this).css("border", "none");
            $(this).parents(".menu").find(".menuBoxDown2").css("display", "block")
        })
    })

    //移入mid_infBox,里面的a变红
    $(function () {
        $(".mid_infBox dd a").on("mouseenter", function () {
            $(this).css("color", "red")
        }).on("mouseleave", function () {
            $(this).css("color", "#666")
        })
    })

    //滚轮事件,滚动滚轮,到150px的时候,顶部的导航栏出现
    $.fn.extend({
        topShow(num = 150) {
            let self = this
            $(window).on("scroll", function () {
                var srcTop = $(this).scrollTop()
                if (srcTop > num) {
                    $(self).css("display", "block")
                } else {
                    $(self).css("display", "none")
                }
            })
        }
    })
    $(function () {
        $(".src_Box").topShow()
    })

    //鼠标移入右边固定导航栏,弹出文字和改变颜色
    $(function () {
        $(".winBox li").on("mouseenter", function () {
            $(this).find("b").css("display", "block")
            $(this).find("i").css("backgroundColor", "red")
        }).on("mouseleave", function () {
            $(this).find("b").css("display", "none")
            $(this).find("i").css("backgroundColor", "#666")
        })
    })
    $(function () {
        $(".backTop").on("mouseenter", function () {
            $(this).find("b").css("display", "block")
            $(this).find("i").css("backgroundColor", "red")
        }).on("mouseleave", function () {
            $(this).find("b").css("display", "none")
            $(this).find("i").css("backgroundColor", "#666")
        })
    })
    //点击回到顶部
    $(function () {
        $(".backTop").on("click", function () {
            $("html,body").animate({
                scrollTop: 0
            })
        })
    })

    //加减
    $(function () {
        //购物车初始化
        var oGoodsList = JSON.parse(localStorage.getItem("oGoods") || "[]")
        $(".shop-car-td-num input").val(oGoodsList[0].num)
        $(".shop-car-td-total b").text(oGoodsList[0].num*oGoodsList[0].price)
        $(".mainselbot_priTop b").text(oGoodsList[0].num*oGoodsList[0].price)
        $(".spa1 b").text(oGoodsList[0].num)

        //减
        $(".reduce").on("click", function () {
            var num = $(this).next().val()
            var num1 = $(this).parents(".mainsel").find(".mainselbot_priBot b").text()
            var price = $(this).parents(".mainselSet").find(".shop-car-td-price span").text()
            var total = $(this).parents(".mainselSet").find(".shop-car-td-total b")
            var total1 = $(this).parents(".mainsel").find(".mainselbot_priTop b")
            num--
            if (num <= 1) {
                num = 1
            }
            num1 = num
            $(this).next().val(num);
            $(this).parents(".mainsel").find(".spa1 b").text(num1)
            total.text(`¥${Number(num) * parseInt(price)}`)
            total1.text(`¥${Number(num) * parseInt(price)}`)
            let oGoodsList = JSON.parse(localStorage.getItem("oGoods") || "[]")
            oGoodsList[0].num = num
            localStorage.setItem("oGoods", JSON.stringify(oGoodsList))
        })
        //加
        $(".plus").on("click", function () {
            var num = $(this).prev().val()
            var num1 = $(this).parents(".mainsel").find(".mainselbot_priBot b").text()
            var price = $(this).parents(".mainselSet").find(".shop-car-td-price span").text()
            var total = $(this).parents(".mainselSet").find(".shop-car-td-total b")
            var total1 = $(this).parents(".mainsel").find(".mainselbot_priTop b")
            num++
            num1 = num
            $(this).prev().val(num);
            $(this).parents(".mainsel").find(".spa1 b").text(num1)
            total.text(`¥${Number(num) * parseInt(price)}.00`)
            total1.text(`¥${Number(num) * parseInt(price)}.00`)
            let oGoodsList = JSON.parse(localStorage.getItem("oGoods") || "[]")
            oGoodsList[0].num = num
            localStorage.setItem("oGoods", JSON.stringify(oGoodsList))
        })
    })
    //删除
    $(function () {
        $(".del").on('click', function () {
            $(this).parents(".mainsel").find(".mainselbot_priTop b").text(0)
            $(this).parents(".mainsel").find(".spa1 b").text(0)
            $(this).parents(".mainselSet").remove()
            localStorage.removeItem("oGoods")
        })
    })

})();